﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Z2102WinForms.LX
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();

            InitializeComponent();

            label1.Text = "上机练习5 类型转换（要求分别用Console和WinForms实现）。";
            label2.AutoEllipsis = true;
            button1.Click += Button1_Click;

            panel1.Visible = false;
            buttonConsole.Click += delegate
            {
                Program.ExecConsoleApp("Z2102Console.LX.Class5");
            };
            buttonWinForms.Click += delegate
            {
                panel1.Visible = true;
            };
        }

        private void Button1_Click(object? sender, EventArgs e)
        {
            string str = textBox1.Text;
            if (int.TryParse(str, out int n) == false)
            {
                label2.Text = "输入的不是整数，请重新输入。";
                return;
            }
            if (n < 0)
            {
                this.Close();
                return;
            }
            string s = "";
            for (int j = 1; j <= n; j++)
            {
                s += j + " ";
            }
            s += "\r\n";
            label2.Text = s;
        }
    }
}
